package config

type Mysql struct {
	Host              string `json:"host" yaml:"host" mapstructure:"host"`
	Port              string `json:"port" yaml:"yaml" mapstructure:"port"`
	Config            string `json:"config" yaml:"config" mapstructure:"config"`
	DB                string `json:"db" yaml:"db" mapstructure:"db"`
	User              string `json:"user" yaml:"user" mapstructure:"user"`
	Password          string `json:"password" yaml:"password" mapstructure:"password"`
	MaxIdleConnection int    `json:"max-idle-connection" yaml:"max-idle-connection" mapstructure:"max-idle-connection"`
	MaxOpenConnection int    `json:"max-open-connection" yaml:"max-open-connection" mapstructure:"max-open-connection"`
}

func (m *Mysql) Dsn() string {
	return m.User + ":" + m.Password + "@tcp(" + m.Host + ":" + m.Port + ")/" + m.DB + "?" + m.Config
}
